package summary;

/**
 * @Author: 海琳琦
 * @Date: 2022/3/7 9:13
 * https://leetcode-cn.com/problems/remove-element/
 */
public class Title27 {

    public static int removeElement(int[] nums, int val) {
        int left = 0;
        for (int right = 0; right < nums.length; right++) {
            if (nums[right] != val) {
                nums[left] = nums[right];
                left++;
            }
        }
        return left + 1;
    }

    public static void main(String[] args) {
        int[] nums = {0,1,2,2,3,0,4,2};
        removeElement(nums, 2);
    }
}
